﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using DAL = AccessDAL;

namespace BLL
{
    public class BaseInfo
    {
        DAL.BaseInfoTableAdapters.BaseInfoTableAdapter DBI =
            new DAL.BaseInfoTableAdapters.BaseInfoTableAdapter();

        MODEL.BaseInfo MBI = new MODEL.BaseInfo();
        MODEL.BaseInfo _MBI = new MODEL.BaseInfo();

        #region GetDataByID
        /// <summary>
        /// GetDataByID
        /// </summary>
        /// <param name="MBI"></param>
        /// <returns></returns>
        public MODEL.BaseInfo GetDataByID(MODEL.BaseInfo MBI)
        {
            try
            {
                DataTable DT = DBI.GetDataByID(MBI.BI_ID);

                _MBI.BI_Content = DT.Rows[0]["BI_Content"].ToString();
                _MBI.BI_DateTime = Convert.ToDateTime(DT.Rows[0]["BI_DateTime"]);
                _MBI.BI_ID = Convert.ToInt32(DT.Rows[0]["BI_ID"]);
                _MBI.BI_Title = DT.Rows[0]["BI_Title"].ToString();

                return _MBI;
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        #endregion


        #region 修改网站基本信息
        /// <summary>
        /// 修改网站基本信息
        /// </summary>
        /// <param name="MBI"></param>
        public void Mod(MODEL.BaseInfo MBI)
        {
            try
            {
                DBI.Mod(MBI.BI_Content, MBI.BI_ID);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        #endregion
    }
}
